import redis

pool = redis.ConnectionPool(host='127.0.0.1', port=6379)

r = redis.Redis(connection_pool=pool)

if __name__ == '__main__':
    import time

    r.set("foo", "whw", ex=1)
    print(r.get("foo"))
    print("1>>> ", r.exists("foo"))
    time.sleep(1.2)
    print("2>>>", r.exists("foo"))
